home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / gcc-2.6.3-bin.lha / GNU / info / gcc.info-11 (.txt) < prev    next >
GNU Info File  |  1995-03-30  |  39KB  |  654 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993, 1994 Free Software Foundation,
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License," "Funding for
  13. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  14. included exactly as in the original, and provided that the entire
  15. resulting derived work is distributed under the terms of a permission
  16. notice identical to this one.
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that the sections entitled "GNU General Public
  20. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  21. `Look And Feel'", and this permission notice, may be included in
  22. translations approved by the Free Software Foundation instead of in the
  23. original English.
  24. File: gcc.info,  Node: Bug Reporting,  Next: Sending Patches,  Prev: Bug Lists,  Up: Bugs
  25. How to Report Bugs
  26. ==================
  27.    The fundamental principle of reporting bugs usefully is this:
  28. *report all the facts*.  If you are not sure whether to state a fact or
  29. leave it out, state it!
  30.    Often people omit facts because they think they know what causes the
  31. problem and they conclude that some details don't matter.  Thus, you
  32. might assume that the name of the variable you use in an example does
  33. not matter.  Well, probably it doesn't, but one cannot be sure.
  34. Perhaps the bug is a stray memory reference which happens to fetch from
  35. the location where that name is stored in memory; perhaps, if the name
  36. were different, the contents of that location would fool the compiler
  37. into doing the right thing despite the bug.  Play it safe and give a
  38. specific, complete example.  That is the easiest thing for you to do,
  39. and the most helpful.
  40.    Keep in mind that the purpose of a bug report is to enable someone to
  41. fix the bug if it is not known.  It isn't very important what happens if
  42. the bug is already known.  Therefore, always write your bug reports on
  43. the assumption that the bug is not known.
  44.    Sometimes people give a few sketchy facts and ask, "Does this ring a
  45. bell?"  This cannot help us fix a bug, so it is basically useless.  We
  46. respond by asking for enough details to enable us to investigate.  You
  47. might as well expedite matters by sending them to begin with.
  48.    Try to make your bug report self-contained.  If we have to ask you
  49. for more information, it is best if you include all the previous
  50. information in your response, as well as the information that was
  51. missing.
  52.    Please report each bug in a separate message.  This makes it easier
  53. for us to track which bugs have been fixed and to forward your bugs
  54. reports to the appropriate maintainer.
  55.    To enable someone to investigate the bug, you should include all
  56. these things:
  57.    * The version of GNU CC.  You can get this by running it with the
  58.      `-v' option.
  59.      Without this, we won't know whether there is any point in looking
  60.      for the bug in the current version of GNU CC.
  61.    * A complete input file that will reproduce the bug.  If the bug is
  62.      in the C preprocessor, send a source file and any header files
  63.      that it requires.  If the bug is in the compiler proper (`cc1'),
  64.      run your source file through the C preprocessor by doing `gcc -E
  65.      SOURCEFILE > OUTFILE', then include the contents of OUTFILE in the
  66.      bug report.  (When you do this, use the same `-I', `-D' or `-U'
  67.      options that you used in actual compilation.)
  68.      A single statement is not enough of an example.  In order to
  69.      compile it, it must be embedded in a complete file of compiler
  70.      input; and the bug might depend on the details of how this is done.
  71.      Without a real example one can compile, all anyone can do about
  72.      your bug report is wish you luck.  It would be futile to try to
  73.      guess how to provoke the bug.  For example, bugs in register
  74.      allocation and reloading frequently depend on every little detail
  75.      of the function they happen in.
  76.      Even if the input file that fails comes from a GNU program, you
  77.      should still send the complete test case.  Don't ask the GNU CC
  78.      maintainers to do the extra work of obtaining the program in
  79.      question--they are all overworked as it is.  Also, the problem may
  80.      depend on what is in the header files on your system; it is
  81.      unreliable for the GNU CC maintainers to try the problem with the
  82.      header files available to them.  By sending CPP output, you can
  83.      eliminate this source of uncertainty and save us a certain
  84.      percentage of wild goose chases.
  85.    * The command arguments you gave GNU CC or GNU C++ to compile that
  86.      example and observe the bug.  For example, did you use `-O'?  To
  87.      guarantee you won't omit something important, list all the options.
  88.      If we were to try to guess the arguments, we would probably guess
  89.      wrong and then we would not encounter the bug.
  90.    * The type of machine you are using, and the operating system name
  91.      and version number.
  92.    * The operands you gave to the `configure' command when you installed
  93.      the compiler.
  94.    * A complete list of any modifications you have made to the compiler
  95.      source.  (We don't promise to investigate the bug unless it
  96.      happens in an unmodified compiler.  But if you've made
  97.      modifications and don't tell us, then you are sending us on a wild
  98.      goose chase.)
  99.      Be precise about these changes.  A description in English is not
  100.      enough--send a context diff for them.
  101.      Adding files of your own (such as a machine description for a
  102.      machine we don't support) is a modification of the compiler source.
  103.    * Details of any other deviations from the standard procedure for
  104.      installing GNU CC.
  105.    * A description of what behavior you observe that you believe is
  106.      incorrect.  For example, "The compiler gets a fatal signal," or,
  107.      "The assembler instruction at line 208 in the output is incorrect."
  108.      Of course, if the bug is that the compiler gets a fatal signal,
  109.      then one can't miss it.  But if the bug is incorrect output, the
  110.      maintainer might not notice unless it is glaringly wrong.  None of
  111.      us has time to study all the assembler code from a 50-line C
  112.      program just on the chance that one instruction might be wrong.
  113.      We need *you* to do this part!
  114.      Even if the problem you experience is a fatal signal, you should
  115.      still say so explicitly.  Suppose something strange is going on,
  116.      such as, your copy of the compiler is out of synch, or you have
  117.      encountered a bug in the C library on your system.  (This has
  118.      happened!)  Your copy might crash and the copy here would not.  If
  119.      you said to expect a crash, then when the compiler here fails to
  120.      crash, we would know that the bug was not happening.  If you don't
  121.      say to expect a crash, then we would not know whether the bug was
  122.      happening.  We would not be able to draw any conclusion from our
  123.      observations.
  124.      If the problem is a diagnostic when compiling GNU CC with some
  125.      other compiler, say whether it is a warning or an error.
  126.      Often the observed symptom is incorrect output when your program
  127.      is run.  Sad to say, this is not enough information unless the
  128.      program is short and simple.  None of us has time to study a large
  129.      program to figure out how it would work if compiled correctly,
  130.      much less which line of it was compiled wrong.  So you will have
  131.      to do that.  Tell us which source line it is, and what incorrect
  132.      result happens when that line is executed.  A person who
  133.      understands the program can find this as easily as finding a bug
  134.      in the program itself.
  135.    * If you send examples of assembler code output from GNU CC or GNU
  136.      C++, please use `-g' when you make them.  The debugging information
  137.      includes source line numbers which are essential for correlating
  138.      the output with the input.
  139.    * If you wish to mention something in the GNU CC source, refer to it
  140.      by context, not by line number.
  141.      The line numbers in the development sources don't match those in
  142.      your sources.  Your line numbers would convey no useful
  143.      information to the maintainers.
  144.    * Additional information from a debugger might enable someone to
  145.      find a problem on a machine which he does not have available.
  146.      However, you need to think when you collect this information if
  147.      you want it to have any chance of being useful.
  148.      For example, many people send just a backtrace, but that is never
  149.      useful by itself.  A simple backtrace with arguments conveys little
  150.      about GNU CC because the compiler is largely data-driven; the same
  151.      functions are called over and over for different RTL insns, doing
  152.      different things depending on the details of the insn.
  153.      Most of the arguments listed in the backtrace are useless because
  154.      they are pointers to RTL list structure.  The numeric values of the
  155.      pointers, which the debugger prints in the backtrace, have no
  156.      significance whatever; all that matters is the contents of the
  157.      objects they point to (and most of the contents are other such
  158.      pointers).
  159.      In addition, most compiler passes consist of one or more loops that
  160.      scan the RTL insn sequence.  The most vital piece of information
  161.      about such a loop--which insn it has reached--is usually in a
  162.      local variable, not in an argument.
  163.      What you need to provide in addition to a backtrace are the values
  164.      of the local variables for several stack frames up.  When a local
  165.      variable or an argument is an RTX, first print its value and then
  166.      use the GDB command `pr' to print the RTL expression that it points
  167.      to.  (If GDB doesn't run on your machine, use your debugger to call
  168.      the function `debug_rtx' with the RTX as an argument.)  In
  169.      general, whenever a variable is a pointer, its value is no use
  170.      without the data it points to.
  171.    Here are some things that are not necessary:
  172.    * A description of the envelope of the bug.
  173.      Often people who encounter a bug spend a lot of time investigating
  174.      which changes to the input file will make the bug go away and which
  175.      changes will not affect it.
  176.      This is often time consuming and not very useful, because the way
  177.      we will find the bug is by running a single example under the
  178.      debugger with breakpoints, not by pure deduction from a series of
  179.      examples.  You might as well save your time for something else.
  180.      Of course, if you can find a simpler example to report *instead* of
  181.      the original one, that is a convenience.  Errors in the output
  182.      will be easier to spot, running under the debugger will take less
  183.      time, etc.  Most GNU CC bugs involve just one function, so the
  184.      most straightforward way to simplify an example is to delete all
  185.      the function definitions except the one where the bug occurs.
  186.      Those earlier in the file may be replaced by external declarations
  187.      if the crucial function depends on them.  (Exception: inline
  188.      functions may affect compilation of functions defined later in the
  189.      file.)
  190.      However, simplification is not vital; if you don't want to do this,
  191.      report the bug anyway and send the entire test case you used.
  192.    * In particular, some people insert conditionals `#ifdef BUG' around
  193.      a statement which, if removed, makes the bug not happen.  These
  194.      are just clutter; we won't pay any attention to them anyway.
  195.      Besides, you should send us cpp output, and that can't have
  196.      conditionals.
  197.    * A patch for the bug.
  198.      A patch for the bug is useful if it is a good one.  But don't omit
  199.      the necessary information, such as the test case, on the
  200.      assumption that a patch is all we need.  We might see problems
  201.      with your patch and decide to fix the problem another way, or we
  202.      might not understand it at all.
  203.      Sometimes with a program as complicated as GNU CC it is very hard
  204.      to construct an example that will make the program follow a
  205.      certain path through the code.  If you don't send the example, we
  206.      won't be able to construct one, so we won't be able to verify that
  207.      the bug is fixed.
  208.      And if we can't understand what bug you are trying to fix, or why
  209.      your patch should be an improvement, we won't install it.  A test
  210.      case will help us to understand.
  211.      *Note Sending Patches::, for guidelines on how to make it easy for
  212.      us to understand and install your patches.
  213.    * A guess about what the bug is or what it depends on.
  214.      Such guesses are usually wrong.  Even I can't guess right about
  215.      such things without first using the debugger to find the facts.
  216.    * A core dump file.
  217.      We have no way of examining a core dump for your type of machine
  218.      unless we have an identical system--and if we do have one, we
  219.      should be able to reproduce the crash ourselves.
  220. File: gcc.info,  Node: Sending Patches,  Prev: Bug Reporting,  Up: Bugs
  221. Sending Patches for GNU CC
  222. ==========================
  223.    If you would like to write bug fixes or improvements for the GNU C
  224. compiler, that is very helpful.  When you send your changes, please
  225. follow these guidelines to avoid causing extra work for us in studying
  226. the patches.
  227.    If you don't follow these guidelines, your information might still be
  228. useful, but using it will take extra work.  Maintaining GNU C is a lot
  229. of work in the best of circumstances, and we can't keep up unless you do
  230. your best to help.
  231.    * Send an explanation with your changes of what problem they fix or
  232.      what improvement they bring about.  For a bug fix, just include a
  233.      copy of the bug report, and explain why the change fixes the bug.
  234.      (Referring to a bug report is not as good as including it, because
  235.      then we will have to look it up, and we have probably already
  236.      deleted it if we've already fixed the bug.)
  237.    * Always include a proper bug report for the problem you think you
  238.      have fixed.  We need to convince ourselves that the change is
  239.      right before installing it.  Even if it is right, we might have
  240.      trouble judging it if we don't have a way to reproduce the problem.
  241.    * Include all the comments that are appropriate to help people
  242.      reading the source in the future understand why this change was
  243.      needed.
  244.    * Don't mix together changes made for different reasons.  Send them
  245.      *individually*.
  246.      If you make two changes for separate reasons, then we might not
  247.      want to install them both.  We might want to install just one.  If
  248.      you send them all jumbled together in a single set of diffs, we
  249.      have to do extra work to disentangle them--to figure out which
  250.      parts of the change serve which purpose.  If we don't have time
  251.      for this, we might have to ignore your changes entirely.
  252.      If you send each change as soon as you have written it, with its
  253.      own explanation, then the two changes never get tangled up, and we
  254.      can consider each one properly without any extra work to
  255.      disentangle them.
  256.      Ideally, each change you send should be impossible to subdivide
  257.      into parts that we might want to consider separately, because each
  258.      of its parts gets its motivation from the other parts.
  259.    * Send each change as soon as that change is finished.  Sometimes
  260.      people think they are helping us by accumulating many changes to
  261.      send them all together.  As explained above, this is absolutely
  262.      the worst thing you could do.
  263.      Since you should send each change separately, you might as well
  264.      send it right away.  That gives us the option of installing it
  265.      immediately if it is important.
  266.    * Use `diff -c' to make your diffs.  Diffs without context are hard
  267.      for us to install reliably.  More than that, they make it hard for
  268.      us to study the diffs to decide whether we want to install them.
  269.      Unidiff format is better than contextless diffs, but not as easy
  270.      to read as `-c' format.
  271.      If you have GNU diff, use `diff -cp', which shows the name of the
  272.      function that each change occurs in.
  273.    * Write the change log entries for your changes.  We get lots of
  274.      changes, and we don't have time to do all the change log writing
  275.      ourselves.
  276.      Read the `ChangeLog' file to see what sorts of information to put
  277.      in, and to learn the style that we use.  The purpose of the change
  278.      log is to show people where to find what was changed.  So you need
  279.      to be specific about what functions you changed; in large
  280.      functions, it's often helpful to indicate where within the
  281.      function the change was.
  282.      On the other hand, once you have shown people where to find the
  283.      change, you need not explain its purpose.  Thus, if you add a new
  284.      function, all you need to say about it is that it is new.  If you
  285.      feel that the purpose needs explaining, it probably does--but the
  286.      explanation will be much more useful if you put it in comments in
  287.      the code.
  288.      If you would like your name to appear in the header line for who
  289.      made the change, send us the header line.
  290.    * When you write the fix, keep in mind that we can't install a
  291.      change that would break other systems.
  292.      People often suggest fixing a problem by changing
  293.      machine-independent files such as `toplev.c' to do something
  294.      special that a particular system needs.  Sometimes it is totally
  295.      obvious that such changes would break GNU CC for almost all users.
  296.      We can't possibly make a change like that.  At best it might tell
  297.      us how to write another patch that would solve the problem
  298.      acceptably.
  299.      Sometimes people send fixes that *might* be an improvement in
  300.      general--but it is hard to be sure of this.  It's hard to install
  301.      such changes because we have to study them very carefully.  Of
  302.      course, a good explanation of the reasoning by which you concluded
  303.      the change was correct can help convince us.
  304.      The safest changes are changes to the configuration files for a
  305.      particular machine.  These are safe because they can't create new
  306.      bugs on other machines.
  307.      Please help us keep up with the workload by designing the patch in
  308.      a form that is good to install.
  309. File: gcc.info,  Node: Service,  Next: VMS,  Prev: Bugs,  Up: Top
  310. How To Get Help with GNU CC
  311. ***************************
  312.    If you need help installing, using or changing GNU CC, there are two
  313. ways to find it:
  314.    * Send a message to a suitable network mailing list.  First try
  315.      `bug-gcc@prep.ai.mit.edu', and if that brings no response, try
  316.      `help-gcc@prep.ai.mit.edu'.
  317.    * Look in the service directory for someone who might help you for a
  318.      fee.  The service directory is found in the file named `SERVICE'
  319.      in the GNU CC distribution.
  320. File: gcc.info,  Node: VMS,  Next: Portability,  Prev: Service,  Up: Top
  321. Using GNU CC on VMS
  322. *******************
  323.    Here is how to use GNU CC on VMS.
  324. * Menu:
  325. * Include Files and VMS::  Where the preprocessor looks for the include files.
  326. * Global Declarations::    How to do globaldef, globalref and globalvalue with
  327.                            GNU CC.
  328. * VMS Misc::           Misc information.
  329. File: gcc.info,  Node: Include Files and VMS,  Next: Global Declarations,  Up: VMS
  330. Include Files and VMS
  331. =====================
  332.    Due to the differences between the filesystems of Unix and VMS, GNU
  333. CC attempts to translate file names in `#include' into names that VMS
  334. will understand.  The basic strategy is to prepend a prefix to the
  335. specification of the include file, convert the whole filename to a VMS
  336. filename, and then try to open the file.  GNU CC tries various prefixes
  337. one by one until one of them succeeds:
  338.   1. The first prefix is the `GNU_CC_INCLUDE:' logical name: this is
  339.      where GNU C header files are traditionally stored.  If you wish to
  340.      store header files in non-standard locations, then you can assign
  341.      the logical `GNU_CC_INCLUDE' to be a search list, where each
  342.      element of the list is suitable for use with a rooted logical.
  343.   2. The next prefix tried is `SYS$SYSROOT:[SYSLIB.]'.  This is where
  344.      VAX-C header files are traditionally stored.
  345.   3. If the include file specification by itself is a valid VMS
  346.      filename, the preprocessor then uses this name with no prefix in
  347.      an attempt to open the include file.
  348.   4. If the file specification is not a valid VMS filename (i.e. does
  349.      not contain a device or a directory specifier, and contains a `/'
  350.      character), the preprocessor tries to convert it from Unix syntax
  351.      to VMS syntax.
  352.      Conversion works like this: the first directory name becomes a
  353.      device, and the rest of the directories are converted into
  354.      VMS-format directory names.  For example, the name `X11/foobar.h'
  355.      is translated to `X11:[000000]foobar.h' or `X11:foobar.h',
  356.      whichever one can be opened.  This strategy allows you to assign a
  357.      logical name to point to the actual location of the header files.
  358.   5. If none of these strategies succeeds, the `#include' fails.
  359.    Include directives of the form:
  360.      #include foobar
  361. are a common source of incompatibility between VAX-C and GNU CC.  VAX-C
  362. treats this much like a standard `#include <foobar.h>' directive.  That
  363. is incompatible with the ANSI C behavior implemented by GNU CC: to
  364. expand the name `foobar' as a macro.  Macro expansion should eventually
  365. yield one of the two standard formats for `#include':
  366.      #include "FILE"
  367.      #include <FILE>
  368.    If you have this problem, the best solution is to modify the source
  369. to convert the `#include' directives to one of the two standard forms.
  370. That will work with either compiler.  If you want a quick and dirty fix,
  371. define the file names as macros with the proper expansion, like this:
  372.      #define stdio <stdio.h>
  373. This will work, as long as the name doesn't conflict with anything else
  374. in the program.
  375.    Another source of incompatibility is that VAX-C assumes that:
  376.      #include "foobar"
  377. is actually asking for the file `foobar.h'.  GNU CC does not make this
  378. assumption, and instead takes what you ask for literally; it tries to
  379. read the file `foobar'.  The best way to avoid this problem is to
  380. always specify the desired file extension in your include directives.
  381.    GNU CC for VMS is distributed with a set of include files that is
  382. sufficient to compile most general purpose programs.  Even though the
  383. GNU CC distribution does not contain header files to define constants
  384. and structures for some VMS system-specific functions, there is no
  385. reason why you cannot use GNU CC with any of these functions.  You first
  386. may have to generate or create header files, either by using the public
  387. domain utility `UNSDL' (which can be found on a DECUS tape), or by
  388. extracting the relevant modules from one of the system macro libraries,
  389. and using an editor to construct a C header file.
  390.    A `#include' file name cannot contain a DECNET node name.  The
  391. preprocessor reports an I/O error if you attempt to use a node name,
  392. whether explicitly, or implicitly via a logical name.
  393. File: gcc.info,  Node: Global Declarations,  Next: VMS Misc,  Prev: Include Files and VMS,  Up: VMS
  394. Global Declarations and VMS
  395. ===========================
  396.    GNU CC does not provide the `globalref', `globaldef' and
  397. `globalvalue' keywords of VAX-C.  You can get the same effect with an
  398. obscure feature of GAS, the GNU assembler.  (This requires GAS version
  399. 1.39 or later.)  The following macros allow you to use this feature in
  400. a fairly natural way:
  401.      #ifdef __GNUC__
  402.      #define GLOBALREF(TYPE,NAME)                      \
  403.        TYPE NAME                                       \
  404.        asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME)
  405.      #define GLOBALDEF(TYPE,NAME,VALUE)                \
  406.        TYPE NAME                                       \
  407.        asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME) \
  408.          = VALUE
  409.      #define GLOBALVALUEREF(TYPE,NAME)                 \
  410.        const TYPE NAME[1]                              \
  411.        asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME)
  412.      #define GLOBALVALUEDEF(TYPE,NAME,VALUE)           \
  413.        const TYPE NAME[1]                              \
  414.        asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME)  \
  415.          = {VALUE}
  416.      #else
  417.      #define GLOBALREF(TYPE,NAME) \
  418.        globalref TYPE NAME
  419.      #define GLOBALDEF(TYPE,NAME,VALUE) \
  420.        globaldef TYPE NAME = VALUE
  421.      #define GLOBALVALUEDEF(TYPE,NAME,VALUE) \
  422.        globalvalue TYPE NAME = VALUE
  423.      #define GLOBALVALUEREF(TYPE,NAME) \
  424.        globalvalue TYPE NAME
  425.      #endif
  426. (The `_$$PsectAttributes_GLOBALSYMBOL' prefix at the start of the name
  427. is removed by the assembler, after it has modified the attributes of
  428. the symbol).  These macros are provided in the VMS binaries
  429. distribution in a header file `GNU_HACKS.H'.  An example of the usage
  430.      GLOBALREF (int, ijk);
  431.      GLOBALDEF (int, jkl, 0);
  432.    The macros `GLOBALREF' and `GLOBALDEF' cannot be used
  433. straightforwardly for arrays, since there is no way to insert the array
  434. dimension into the declaration at the right place.  However, you can
  435. declare an array with these macros if you first define a typedef for the
  436. array type, like this:
  437.      typedef int intvector[10];
  438.      GLOBALREF (intvector, foo);
  439.    Array and structure initializers will also break the macros; you can
  440. define the initializer to be a macro of its own, or you can expand the
  441. `GLOBALDEF' macro by hand.  You may find a case where you wish to use
  442. the `GLOBALDEF' macro with a large array, but you are not interested in
  443. explicitly initializing each element of the array.  In such cases you
  444. can use an initializer like: `{0,}', which will initialize the entire
  445. array to `0'.
  446.    A shortcoming of this implementation is that a variable declared with
  447. `GLOBALVALUEREF' or `GLOBALVALUEDEF' is always an array.  For example,
  448. the declaration:
  449.      GLOBALVALUEREF(int, ijk);
  450. declares the variable `ijk' as an array of type `int [1]'.  This is
  451. done because a globalvalue is actually a constant; its "value" is what
  452. the linker would normally consider an address.  That is not how an
  453. integer value works in C, but it is how an array works.  So treating
  454. the symbol as an array name gives consistent results--with the
  455. exception that the value seems to have the wrong type.  *Don't try to
  456. access an element of the array.*  It doesn't have any elements.  The
  457. array "address" may not be the address of actual storage.
  458.    The fact that the symbol is an array may lead to warnings where the
  459. variable is used.  Insert type casts to avoid the warnings.  Here is an
  460. example; it takes advantage of the ANSI C feature allowing macros that
  461. expand to use the same name as the macro itself.
  462.      GLOBALVALUEREF (int, ss$_normal);
  463.      GLOBALVALUEDEF (int, xyzzy,123);
  464.      #ifdef __GNUC__
  465.      #define ss$_normal ((int) ss$_normal)
  466.      #define xyzzy ((int) xyzzy)
  467.      #endif
  468.    Don't use `globaldef' or `globalref' with a variable whose type is
  469. an enumeration type; this is not implemented.  Instead, make the
  470. variable an integer, and use a `globalvaluedef' for each of the
  471. enumeration values.  An example of this would be:
  472.      #ifdef __GNUC__
  473.      GLOBALDEF (int, color, 0);
  474.      GLOBALVALUEDEF (int, RED, 0);
  475.      GLOBALVALUEDEF (int, BLUE, 1);
  476.      GLOBALVALUEDEF (int, GREEN, 3);
  477.      #else
  478.      enum globaldef color {RED, BLUE, GREEN = 3};
  479.      #endif
  480. File: gcc.info,  Node: VMS Misc,  Prev: Global Declarations,  Up: VMS
  481. Other VMS Issues
  482. ================
  483.    GNU CC automatically arranges for `main' to return 1 by default if
  484. you fail to specify an explicit return value.  This will be interpreted
  485. by VMS as a status code indicating a normal successful completion.
  486. Version 1 of GNU CC did not provide this default.
  487.    GNU CC on VMS works only with the GNU assembler, GAS.  You need
  488. version 1.37 or later of GAS in order to produce value debugging
  489. information for the VMS debugger.  Use the ordinary VMS linker with the
  490. object files produced by GAS.
  491.    Under previous versions of GNU CC, the generated code would
  492. occasionally give strange results when linked to the sharable `VAXCRTL'
  493. library.  Now this should work.
  494.    A caveat for use of `const' global variables: the `const' modifier
  495. must be specified in every external declaration of the variable in all
  496. of the source files that use that variable.  Otherwise the linker will
  497. issue warnings about conflicting attributes for the variable.  Your
  498. program will still work despite the warnings, but the variable will be
  499. placed in writable storage.
  500.    Although the VMS linker does distinguish between upper and lower case
  501. letters in global symbols, most VMS compilers convert all such symbols
  502. into upper case and most run-time library routines also have upper case
  503. names.  To be able to reliably call such routines, GNU CC (by means of
  504. the assembler GAS) converts global symbols into upper case like other
  505. VMS compilers.  However, since the usual practice in C is to distinguish
  506. case, GNU CC (via GAS) tries to preserve usual C behavior by augmenting
  507. each name that is not all lower case.  This means truncating the name
  508. to at most 23 characters and then adding more characters at the end
  509. which encode the case pattern of those 23.   Names which contain at
  510. least one dollar sign are an exception; they are converted directly into
  511. upper case without augmentation.
  512.    Name augmentation yields bad results for programs that use
  513. precompiled libraries (such as Xlib) which were generated by another
  514. compiler.  You can use the compiler option `/NOCASE_HACK' to inhibit
  515. augmentation; it makes external C functions and variables
  516. case-independent as is usual on VMS.  Alternatively, you could write
  517. all references to the functions and variables in such libraries using
  518. lower case; this will work on VMS, but is not portable to other
  519. systems.  The compiler option `/NAMES' also provides control over
  520. global name handling.
  521.    Function and variable names are handled somewhat differently with GNU
  522. C++.  The GNU C++ compiler performs "name mangling" on function names,
  523. which means that it adds information to the function name to describe
  524. the data types of the arguments that the function takes.  One result of
  525. this is that the name of a function can become very long.  Since the
  526. VMS linker only recognizes the first 31 characters in a name, special
  527. action is taken to ensure that each function and variable has a unique
  528. name that can be represented in 31 characters.
  529.    If the name (plus a name augmentation, if required) is less than 32
  530. characters in length, then no special action is performed.  If the name
  531. is longer than 31 characters, the assembler (GAS) will generate a hash
  532. string based upon the function name, truncate the function name to 23
  533. characters, and append the hash string to the truncated name.  If the
  534. `/VERBOSE' compiler option is used, the assembler will print both the
  535. full and truncated names of each symbol that is truncated.
  536.    The `/NOCASE_HACK' compiler option should not be used when you are
  537. compiling programs that use libg++.  libg++ has several instances of
  538. objects (i.e.  `Filebuf' and `filebuf') which become indistinguishable
  539. in a case-insensitive environment.  This leads to cases where you need
  540. to inhibit augmentation selectively (if you were using libg++ and Xlib
  541. in the same program, for example).  There is no special feature for
  542. doing this, but you can get the result by defining a macro for each
  543. mixed case symbol for which you wish to inhibit augmentation.  The
  544. macro should expand into the lower case equivalent of itself.  For
  545. example:
  546.      #define StuDlyCapS studlycaps
  547.    These macro definitions can be placed in a header file to minimize
  548. the number of changes to your source code.
  549. File: gcc.info,  Node: Portability,  Next: Interface,  Prev: VMS,  Up: Top
  550. GNU CC and Portability
  551. **********************
  552.    The main goal of GNU CC was to make a good, fast compiler for
  553. machines in the class that the GNU system aims to run on: 32-bit
  554. machines that address 8-bit bytes and have several general registers.
  555. Elegance, theoretical power and simplicity are only secondary.
  556.    GNU CC gets most of the information about the target machine from a
  557. machine description which gives an algebraic formula for each of the
  558. machine's instructions.  This is a very clean way to describe the
  559. target.  But when the compiler needs information that is difficult to
  560. express in this fashion, I have not hesitated to define an ad-hoc
  561. parameter to the machine description.  The purpose of portability is to
  562. reduce the total work needed on the compiler; it was not of interest
  563. for its own sake.
  564.    GNU CC does not contain machine dependent code, but it does contain
  565. code that depends on machine parameters such as endianness (whether the
  566. most significant byte has the highest or lowest address of the bytes in
  567. a word) and the availability of autoincrement addressing.  In the
  568. RTL-generation pass, it is often necessary to have multiple strategies
  569. for generating code for a particular kind of syntax tree, strategies
  570. that are usable for different combinations of parameters.  Often I have
  571. not tried to address all possible cases, but only the common ones or
  572. only the ones that I have encountered.  As a result, a new target may
  573. require additional strategies.  You will know if this happens because
  574. the compiler will call `abort'.  Fortunately, the new strategies can be
  575. added in a machine-independent fashion, and will affect only the target
  576. machines that need them.
  577. File: gcc.info,  Node: Interface,  Next: Passes,  Prev: Portability,  Up: Top
  578. Interfacing to GNU CC Output
  579. ****************************
  580.    GNU CC is normally configured to use the same function calling
  581. convention normally in use on the target system.  This is done with the
  582. machine-description macros described (*note Target Macros::.).
  583.    However, returning of structure and union values is done differently
  584. on some target machines.  As a result, functions compiled with PCC
  585. returning such types cannot be called from code compiled with GNU CC,
  586. and vice versa.  This does not cause trouble often because few Unix
  587. library routines return structures or unions.
  588.    GNU CC code returns structures and unions that are 1, 2, 4 or 8 bytes
  589. long in the same registers used for `int' or `double' return values.
  590. (GNU CC typically allocates variables of such types in registers also.)
  591. Structures and unions of other sizes are returned by storing them into
  592. an address passed by the caller (usually in a register).  The
  593. machine-description macros `STRUCT_VALUE' and `STRUCT_INCOMING_VALUE'
  594. tell GNU CC where to pass this address.
  595.    By contrast, PCC on most target machines returns structures and
  596. unions of any size by copying the data into an area of static storage,
  597. and then returning the address of that storage as if it were a pointer
  598. value.  The caller must copy the data from that memory area to the
  599. place where the value is wanted.  This is slower than the method used
  600. by GNU CC, and fails to be reentrant.
  601.    On some target machines, such as RISC machines and the 80386, the
  602. standard system convention is to pass to the subroutine the address of
  603. where to return the value.  On these machines, GNU CC has been
  604. configured to be compatible with the standard compiler, when this method
  605. is used.  It may not be compatible for structures of 1, 2, 4 or 8 bytes.
  606.    GNU CC uses the system's standard convention for passing arguments.
  607. On some machines, the first few arguments are passed in registers; in
  608. others, all are passed on the stack.  It would be possible to use
  609. registers for argument passing on any machine, and this would probably
  610. result in a significant speedup.  But the result would be complete
  611. incompatibility with code that follows the standard convention.  So this
  612. change is practical only if you are switching to GNU CC as the sole C
  613. compiler for the system.  We may implement register argument passing on
  614. certain machines once we have a complete GNU system so that we can
  615. compile the libraries with GNU CC.
  616.    On some machines (particularly the Sparc), certain types of arguments
  617. are passed "by invisible reference".  This means that the value is
  618. stored in memory, and the address of the memory location is passed to
  619. the subroutine.
  620.    If you use `longjmp', beware of automatic variables.  ANSI C says
  621. that automatic variables that are not declared `volatile' have undefined
  622. values after a `longjmp'.  And this is all GNU CC promises to do,
  623. because it is very difficult to restore register variables correctly,
  624. and one of GNU CC's features is that it can put variables in registers
  625. without your asking it to.
  626.    If you want a variable to be unaltered by `longjmp', and you don't
  627. want to write `volatile' because old C compilers don't accept it, just
  628. take the address of the variable.  If a variable's address is ever
  629. taken, even if just to compute it and ignore it, then the variable
  630. cannot go in a register:
  631.      {
  632.        int careful;
  633.        &careful;
  634.        ...
  635.      }
  636.    Code compiled with GNU CC may call certain library routines.  Most of
  637. them handle arithmetic for which there are no instructions.  This
  638. includes multiply and divide on some machines, and floating point
  639. operations on any machine for which floating point support is disabled
  640. with `-msoft-float'.  Some standard parts of the C library, such as
  641. `bcopy' or `memcpy', are also called automatically.  The usual function
  642. call interface is used for calling the library routines.
  643.    These library routines should be defined in the library `libgcc.a',
  644. which GNU CC automatically searches whenever it links a program.  On
  645. machines that have multiply and divide instructions, if hardware
  646. floating point is in use, normally `libgcc.a' is not needed, but it is
  647. searched just in case.
  648.    Each arithmetic function is defined in `libgcc1.c' to use the
  649. corresponding C arithmetic operator.  As long as the file is compiled
  650. with another C compiler, which supports all the C arithmetic operators,
  651. this file will work portably.  However, `libgcc1.c' does not work if
  652. compiled with GNU CC, because each arithmetic function would compile
  653. into a call to itself!
  654.